class Solution {
public:
    bool isPalindrome(int x) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function
        if (x < 0) {
            return false;
        }
        int r = 1;
        while (x / r >= 10) {
            r *= 10;
        }
        int l = 1;
        while (r > l) {
            if (x / r % 10 != x / l % 10) {
                return false;
            }
            r /= 10;
            l *= 10;
        }
        return true;
    }
};
